package main

import "fmt"
import "math/rand"
import "time"

func main() {
	n := 10
	s := make([]int, n)
	initData(s)
	fmt.Println(" before sort : ", s)

	bubbleSort(s)
	fmt.Println(" after sort : ", s)

}

func initData(s []int) {
	rand.Seed(time.Now().UnixNano()) // set-seed
	for j := 0; j < len(s); j++ {
		s[j] = rand.Intn(100) // random number in [1,100]
	}
}

func bubbleSort(array []int) {
	n := len(array)
	for i := 0; i < n-1; i++ {
		for j := 0; j < n-1-i; j++ {
			if array[j] > array[j+1] {
				array[j], array[j+1] = array[j+1], array[j]
			}
		}
	}
}
